package com.framework.common.response;


import com.framework.common.Enums.FrameworkErrorCodeEnum;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * @author zhoubb
 * @version V1.0
 * @Date 2020/1/25 14:07
 * @since JDK 1.8
 */
@Data
@NoArgsConstructor
public class ResponseBaseBean implements Serializable {

    private static final long serialVersionUID = 249711494052023357L;

    private String correlationID;

    private boolean success;

    private String code;

    private String msg;

    /** 交易失败具体原因 */
    private String failReason;



    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("ResponseBaseBean{");
        sb.append("correlationID='").append(correlationID).append('\'');
        sb.append(", retCode='").append(code).append('\'');
        sb.append(", retMsg='").append(msg).append('\'');
        sb.append(", failReason='").append(failReason).append('\'');
        sb.append('}');
        return sb.toString();
    }

    public void setCode(String code) {
        this.code = code;
        if(StringUtils.equals(FrameworkErrorCodeEnum.SUCCESS.getCode(), code)) {
            this.success = true;
        } else {
            this.success = false;
        }

    }
}
